package com.yanqu.road.server.pb;

import com.yanqu.road.entity.activity.luckydraw.LuckyDrawConfig;
import com.yanqu.road.entity.activity.luckydraw.LuckyDrawRewardConfig;
import com.yanqu.road.entity.player.UserRealReward;
import com.yanqu.road.pb.activity.LuckyDrawProto;

public class LuckyDrawPb {

    public static LuckyDrawProto.LuckyDrawSyncConfigRespMsg.Builder parseLuckyDrawSyncConfigRespMsg(LuckyDrawConfig config) {
        LuckyDrawProto.LuckyDrawSyncConfigRespMsg.Builder builder = LuckyDrawProto.LuckyDrawSyncConfigRespMsg.newBuilder();
        for (LuckyDrawRewardConfig luckyDrawRewardConfig : config.getRewardConfigList()) {
            builder.addRewardList(parseLuckyDrawRewardInfo(luckyDrawRewardConfig));
        }
        return builder;
    }

    public static LuckyDrawProto.LuckyDrawRewardInfo.Builder parseLuckyDrawRewardInfo(LuckyDrawRewardConfig config) {
        LuckyDrawProto.LuckyDrawRewardInfo.Builder builder = LuckyDrawProto.LuckyDrawRewardInfo.newBuilder();
        builder.setId(config.getShootId());
        builder.setReward(config.getReward());
        builder.setPlace(config.getPlace());
        return builder;
    }

    public static LuckyDrawProto.LuckyDrawRealRewardMsg.Builder parseLuckyDrawRealRewardMsg(UserRealReward data) {
        LuckyDrawProto.LuckyDrawRealRewardMsg.Builder builder = LuckyDrawProto.LuckyDrawRealRewardMsg.newBuilder();
        builder.setNo(data.getNo());
        builder.setGoodsId(data.getGoodsId());

        if (data.getAddrTime().getTime() != 0) {
            builder.setPhone(data.getPhone());
            builder.setAddr(data.getAddr());
            builder.setSubmitTime(data.getAddrTime().getTime());
        }
        return builder;
    }

}
